<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Grid Layout Comparison</title>
  <style>
    .container {
      margin-bottom: 20px;
    }

    .grid-container {
      display: grid;
      gap: 10px;
      /* 设置列之间的间距 */
    }

    .grid-item {
      background-color: lightblue;
      text-align: center;
      padding: 20px;
      font-size: 20px;
    }
    .item-5 {
      background-color: red;
    }
  </style>
</head>

<body>
  <div class="container">
    <h2>auto-fill</h2>
    <div class="grid-container" style="grid-template-columns: repeat(auto-fill, 100px);">
      <div class="grid-item">1</div>
      <div class="grid-item">2</div>
      <div class="grid-item">3</div>
      <div class="grid-item">4</div>
      <div class="grid-item item-5">5</div>
    </div>
  </div>

  <div class="container">
    <h2>auto-fit</h2>
    <div class="grid-container" style="grid-template-columns: repeat(auto-fit, 100px);">
      <div class="grid-item">1</div>
      <div class="grid-item">2</div>
      <div class="grid-item">3</div>
      <div class="grid-item">4</div>
      <div class="grid-item item-5">5</div>
    </div>
  </div>
</body>

</html>
